<?php

/**
 * pagina php richiamata dalla POST Ajax per verificare se l'utente esiste
 * 
 * @author Stefano Poncini
 * @param string username $_POST
 * @return int
 */
require(__DIR__ . '/../inc/global.inc.php');

$username = mysql_real_escape_string($_POST['username']);

$sql = "SELECT count(*) as num_username from user where username = ?";

$stmt = DB::getDBO()->prepare($sql);
$stmt->execute(array($username));


$result = $stmt->fetch();
if ($result['num_username'] != 0)
    echo 0;
else
    echo 1;
?>